package com.wuyou.sso.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.wuyou.sso.common.entity.User;
import com.wuyou.sso.domain.vo.UserVO;
import com.wuyou.sso.mapper.UserMapper;
import com.wuyou.sso.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;


/**
 * UserServiceImpl
 *
 * @Date 2025/4/24 15:06
 * @Author 无忧
 */
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {

    private final UserMapper userMapper;


    @Override
    public UserVO getUserByUserName(String username) {
        UserVO userVO = new UserVO();
        //查询用户信息 过滤停用和删除
        User user = userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getUsername, username)
                );
        Assert.notNull(user, "用户名或密码错误");
        userVO.setUserInfo(user);
        return userVO;
    }
}
